package movee.domain.common;

import io.swagger.v3.oas.annotations.media.SchemaProperty;
import movee.domain.constants.BackupDomain;
import movee.domain.constants.BackupTaskPriority;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 *
 *
 * @author movee
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BaseBackupDevice implements Serializable {

    /**
     * 表id，自增ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @SchemaProperty(name = "表id，值为null表示创建，不为null表示更新")
    private Long id;


    @TableField(value = "task_id")
    @SchemaProperty(name = "任务id")
    @NotNull(message = "taskId字段不能为null")
    private Long taskId;

    @TableField(value = "priority")
    @SchemaProperty(name = "任务优先级")
    @NotNull(message = "priority字段不能为null")
    private BackupTaskPriority priority;

    @TableField(value = "mgmt_ip")
    @SchemaProperty(name = "管理ip")
    @NotBlank(message = "mgmtIp字段不能为空或null")
    private String mgmtIp;

    @TableField(value = "hostname")
    @SchemaProperty(name = "主机名")
    @NotNull(message = "hostname字段不能为null")
    private String hostname;

    @TableField(value = "idc")
    @SchemaProperty(name = "物理机房")
    @NotNull(message = "idc字段不能为null")
    private String idc;

    @TableField(value = "iaz")
    @SchemaProperty(name = "逻辑机房")
    @NotNull(message = "iaz字段不能为null")
    private String iaz;

    @TableField(value = "cluster")
    @SchemaProperty(name = "集群")
    @NotNull(message = "cluster字段不能为null")
    private String cluster;

    @TableField(value = "pod")
    @SchemaProperty(name = "pod")
    @NotNull(message = "pod字段不能为null")
    private String pod;

    @TableField(value = "role")
    @SchemaProperty(name = "角色")
    @NotNull(message = "role字段不能为null")
    private String role;

    @TableField(value = "vendor")
    @SchemaProperty(name = "厂商")
    @NotNull(message = "vendor字段不能为null")
    private String vendor;

    @TableField(value = "model")
    @SchemaProperty(name = "型号")
    @NotNull(message = "model字段不能为null")
    private String model;

    @TableField(value = "domain")
    @SchemaProperty(name = "设备所属业务域")
    @NotNull(message = "domain字段不能为null")
    private BackupDomain domain;

    @TableField(value = "operator")
    @SchemaProperty(name = "执行人")
    @NotNull(message = "operator字段不能为null")
    private String operator;

    @TableField(value = "work_node")
    @SchemaProperty(name = "执行任务的工作节点")
    @NotBlank(message = "workNode字段不能为空或null")
    private String workNode;

    /**
     * netadmin1
     */
    @TableField(value = "netadmin1")
    @SchemaProperty(name = "netadmin1")
    @NotNull(message = "netadmin1字段不能为null")
    private String netadmin1;

    /**
     * netadmin2
     */
    @TableField(value = "netadmin2")
    @SchemaProperty(name = "netadmin2")
    @NotNull(message = "netadmin2字段不能为null")
    private String netadmin2;

    /**
     * ftpserver1
     */
    @TableField(value = "ftp_server1")
    @SchemaProperty(name = "ftp server1")
    @NotNull(message = "ftpServer1字段不能为null")
    private String ftpServer1;

    /**
     * ftpserver2
     */
    @TableField(value = "ftp_server2")
    @SchemaProperty(name = "ftp server2")
    private String ftpServer2;

    /**
     * 命令模板名
     */
    @TableField(value = "cmd_template")
    @SchemaProperty(name = "命令模板名")
    @NotBlank(message = "cmdTemplate字段不能为null或空")
    private String cmdTemplate = "";

    /**
     * 网络设备本地配置文件名字
     */
    @TableField(value = "local_file_name")
    @SchemaProperty(name = "网络设备本地配置文件名字")
    @NotNull(message = "localFileName字段不能为null")
    private String localFileName;

    /**
     * 网络设备ftpserver配置文件名字
     */
    @TableField(value = "remote_file_name")
    @SchemaProperty(name = "网络设备ftpserver配置文件名字")
    @NotNull(message = "remoteFileName字段不能为null")
    private String remoteFileName;

    /**
     * 备份文件名字
     */
    @TableField(value = "file_name")
    @SchemaProperty(name = "备份文件名字")
    @NotNull(message = "fileName字段不能为null")
    private String fileName;

    /**
     * 操作单是否绑定NSC，0：否；1：是
     */
    @TableField(value = "is_changed")
    @SchemaProperty(name = "与上次备份相比，是否发生了变化")
    @NotNull(message = "changed字段不能为null")
    private Boolean changed;

    /**
     * 失败原因类型
     */
    @TableField(value = "err_msg")
    @SchemaProperty(name = "失败信息")
    private String errMsg;

    /**
     * 指令平台操作id
     */
    @TableField(value = "cmd_id")
    @SchemaProperty(name = "指令平台操作id")
    @NotNull(message = "cmdId字段不能为null")
    private String cmdId;

    /**
     * 开始时间
     */
    @TableField(value = "start_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @SchemaProperty(name = "开始时间")
    private Timestamp startTime;

    /**
     * 结束时间
     */
    @TableField(value = "end_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @SchemaProperty(name = "结束时间")
    private Timestamp endTime;

    /**
     * 操作花费的时间，单位为毫秒
     */
    @TableField(value = "duration_ms")
    @SchemaProperty(name = "执行时间")
    private Long durationMs;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @SchemaProperty(name = "创建时间")
    private Timestamp createTime;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time")
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @SchemaProperty(name = "最后更新时间")
    private Timestamp updateTime;


}
